package cz.proks.bank.client;

import java.util.List;

import javax.xml.ws.WebServiceException;

import org.springframework.stereotype.Service;

import cz.cvut.felk.support.aos.sw.clearingcenter.Payment;
import cz.proks.bank.service.clearingservice.ClearingService;
import cz.proks.bank.service.clearingservice.ClearingService_Service;
import cz.proks.bank.service.clearingservice.FetchPaymentsFaultExceptionException;
import cz.proks.bank.service.clearingservice.GetPaymentsResultFaultExceptionException;
import cz.proks.bank.service.clearingservice.RegisterFaultExceptionException;
import cz.proks.bank.service.clearingservice.SendPaymentsFaultExceptionException;
import cz.proks.bank.service.clearingservice.SetPaymentsResultFaultExceptionException;

@Service
public class ClearingServiceClient implements ClearingService {
	private ClearingService service;
	
	public ClearingServiceClient() throws WebServiceException {
		service = new ClearingService_Service().getClearingServicePort();
	}

	@Override
	public List<Payment> getPaymentsResult(String bankKey, List<Long> paymentIds)
			throws GetPaymentsResultFaultExceptionException {
		return service.getPaymentsResult(bankKey, paymentIds);
	}

	@Override
	public void setPaymentsResult(String bankKey,
			List<Payment> paymentsWithResults)
			throws SetPaymentsResultFaultExceptionException {
		service.setPaymentsResult(bankKey, paymentsWithResults);
	}

	@Override
	public List<Payment> fetchPayments(String bankKey)
			throws FetchPaymentsFaultExceptionException {
		return service.fetchPayments(bankKey);
	}

	@Override
	public List<Long> sendPayments(String bankKey, List<Payment> payments)
			throws SendPaymentsFaultExceptionException {
		return service.sendPayments(bankKey, payments);
	}

	@Override
	public String register(String bankCode)
			throws RegisterFaultExceptionException {
		return service.register(bankCode);
	}
}
